#ifndef __MV_POSITION_SOURCE
#define __MV_POSITION_SOURCE

STRUCT( MVSatInfo )
  bool Valid;
  WORD Index;
  int  Quality;
  int  Azimuth;
  int  Elevation;
};

STRUCT( MVPosInfo )
  double   x,           //Longitude  -180...180
           y;           //Latitude   -90..90
  double   Altitude;   //UNKNOWN_ALTITUDE
  double   Course;     //UNKNOWN_DIR
  double   Speed;
  double   VertSpeed;
  double   PDop;
  double   HDop;
  double   VDop;
  int      Datum;
};

enum PosSrcState {
  pssNotConnect,
  pssNoFix,
  pssFix2d,
  pssFix3d,
};

PRESTRUCT( MVPositionSource );

typedef void __fastcall(__closure *MVPositionEvent)( PMVPositionSource Sender );
typedef MyValArray<MVPositionEvent> MVPositionEvents;
typedef void __fastcall(__closure *MVCommandEvent)( PMVPositionSource Sender, LPVOID Data );
typedef MyValArray<MVCommandEvent> MVCommandEvents;

CLASS( MVPositionSource )
  protected:
    PMVDataHandler   Handler;

  public:
    void idOnNewPosition( void );
    void idOnNewCommand( LPVOID str );

  public:
    MVPositionSource( PMVDataHandler h );
    virtual ~MVPositionSource();

    virtual bool         IsFix( void ) = 0;
    virtual PosSrcState  GetState( void ) = 0;
    virtual void         GetTime( PRTime& tm ) = 0;
    virtual void         GetInfo( MVPosInfo& tm ) = 0;
    virtual int          SatsUsed( void ) = 0;
    virtual int          SatCount( void ) = 0;
    virtual bool         SatItem( int idx, MVSatInfo& si ) = 0;

    virtual bool         Initialize( PHConfigItem cfg ) = 0;
    virtual void         WorkSlice( void ) = 0;
    virtual void         Stop( void ) = 0;

    MVPositionEvents OnNewPosition;
    MVCommandEvents  OnNewCommand;
};

#define MVP_FL_CONFIG      0x00000001UL
#define MVP_FL_NEEDHANDLER 0x00000002UL

STRUCT( MVPositionInfo )
  CONSTSTR Name;
  DWORD    Flags;

  PTForm            __fastcall(__closure *ConfigForm)( void );
  PMVPositionSource __fastcall(__closure *CreateNew)( PMVDataHandler h );
};
#endif